unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, cxControls, cxSSheet,cxSSTypes, ExtCtrls, RzPanel,
  RzCmboBx;

type
  TForm1 = class(TForm)
    cxSpreadSheetBook1: TcxSpreadSheetBook;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Tool_1: TRzToolbar;
    Btnx_1: TButton;
    Comb_1: TRzComboBox;
    procedure FormShow(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Btnx_1Click(Sender: TObject);
    procedure cxSpreadSheetBook1Click(Sender: TObject);
  private
  public
  end;

var
  Form1: TForm1;

implementation

uses
  DateUtils;

{$R *.dfm}

procedure TForm1.FormShow(Sender: TObject);
begin
  //Self.cxSpreadSheetBook1.LoadFromFile('0101.xls');
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  R:TRect;
begin
  R.Left:=0;
  R.Top:=0;
  R.Right:=2;
  R.Bottom:=2;

  //TcxSSCellsModify = (msShiftCol, msShiftRow, msAllCol, msAllRow);
  cxSpreadSheetBook1.ActiveSheet.InsertCells(R,msAllRow);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  cxSpreadSheetBook1.SaveToFile('0101.xls');
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  ShowMessageFmt('%D|%D|%D|%D',[self.cxSpreadSheetBook1.ActiveSheet.SelectionRect.Left,self.cxSpreadSheetBook1.ActiveSheet.SelectionRect.Top,self.cxSpreadSheetBook1.ActiveSheet.SelectionRect.Right,self.cxSpreadSheetBook1.ActiveSheet.SelectionRect.Bottom]);
end;

procedure TForm1.Btnx_1Click(Sender: TObject);
var
  I,M:Integer;
  CellA:TcxSSCellObject;
begin
  with cxSpreadSheetBook1 do
  begin
    BeginUpdate;

    for I:=0 to 255 do
    begin
      CellA:=ActiveSheet.GetCellObject(2,I+3);
      CellA.Style.Brush.BackgroundColor:=I;
      CellA.Text:=Format('Color:%D',[I]);
      CellA.Free;
    end;
    EndUpdate;
  end;  
end;

procedure TForm1.cxSpreadSheetBook1Click(Sender: TObject);
var
  CellA:TcxSSCellObject;
begin
  //
  Comb_1.Visible:=False;
  with cxSpreadSheetBook1 do
  begin
    CellA:=ActiveSheet.GetCellObject(ActiveCell.X,ActiveCell.Y);

    Comb_1.Visible:=True;
    Comb_1.Left :=ActiveSheet.SelectionRect.Left;
    Comb_1.Width:=ActiveSheet.SelectionRect.Right-ActiveSheet.SelectionRect.Left;
  end;
end;

end.
